//对get和post请求的封装

//get请求封装
const req = (urlString, token = '') => {
	const promise = new Promise((res, req) => {
		uni.request({
			url: urlString,
			header: {
				'Authorization': `Bearer ${token}`
			},
			success(result) {
				res(result)
			},
			fail(err) {
				req(err)
			}
		})
	})
	return promise
}

//post请求封装
const post = (urlString, data, token = '') => {
	const promise = new Promise((res, req) => {
		uni.request({
			url: urlString,
			data: data,
			method: "POST",
			header: {
				'content-type': 'application/json',
				'Authorization': `Bearer ${token}`
			},
			success(result) {
				res(result)
			},
			fail(err) {
				req(err)
			}
		})
	})
	return promise
}

export {
	req,
	post
}